import sys

class Solution(object):
    def majorityElement(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        nums.sort()
        maxSum = 0
        maxNum = sys.maxsize
        sum = 0
        lastNum = sys.maxsize
        for num in nums:
            if num != lastNum:
                sum = 1
            else:
                sum += 1
            lastNum = num
            if sum > maxSum:
                maxSum = sum
                maxNum = num
        return maxNum

print(Solution().majorityElement([1,2,3,4,5,6,7,7]))